/**@Title   GradeController.java
 * @Package com.gong.controller
 * @Desc    
 * @Author  GongWenhua
 * @Date    2017年7月17日 下午2:35:13
 * @Version 1.0
*/
package com.gong.controller;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.gong.bean.Grade;
import com.gong.service.GradeService;

@RestController
public class GradeController {
	
	@Resource
	private GradeService gradeService;
	
	
	
	@RequestMapping("/findByGradeNum")
	public Grade findByGradeNum(String gradeNum){
		System.out.println("findGradeNum");
		return gradeService.findByGradeNum(gradeNum);
	}
	
	@RequestMapping("/findByGradeNumJPQL")
	public Grade findByGradeNumJPQL(String gradeNum){
		System.out.println("findGradeNumJPQL");
		return gradeService.findByGradeNumJPQL(gradeNum);
	}
	
	@RequestMapping("/save")
	public void save(){
		System.out.println("findGradeNum2");
		Grade grade = new Grade();
		grade.setGradeNum("1006");
		grade.setTeacherId(3);
		gradeService.save(grade);
	}
	@RequestMapping("/delete")
	public void delete(){
		System.out.println("delete");
		gradeService.delete(1);
	}
	
	@RequestMapping("/findAll")
	public Iterable<Grade> findAll(){
		return gradeService.findAll();
	}
	
	@RequestMapping("/findAll2")
	public Iterable<Grade> findAll2(){
		return gradeService.findAll2();
	}
}
